package com.sddnytsh.body_buildingsystem

import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.activity.enableEdgeToEdge
import androidx.navigation.compose.NavHost
import androidx.navigation.compose.composable
import androidx.navigation.compose.rememberNavController
import com.sddnytsh.body_buildingsystem.screens.AboutScreen
import com.sddnytsh.body_buildingsystem.screens.CreatePostScreen
import com.sddnytsh.body_buildingsystem.screens.HelpAndFeedbackScreen
import com.sddnytsh.body_buildingsystem.screens.LoginScreen
import com.sddnytsh.body_buildingsystem.screens.MainScreen
import com.sddnytsh.body_buildingsystem.screens.PostDetailScreen
import com.sddnytsh.body_buildingsystem.screens.ProfileScreen
import com.sddnytsh.body_buildingsystem.screens.RegisterScreen
import com.sddnytsh.body_buildingsystem.screens.SettingsScreen
import com.sddnytsh.body_buildingsystem.ui.theme.BodybuildingSystemTheme

class MainActivity : ComponentActivity() {


    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        enableEdgeToEdge()
        setContent {
            BodybuildingSystemTheme {
                val navController = rememberNavController()

                NavHost(navController = navController, startDestination = "login") {
                    composable("login") {
                        LoginScreen(navController = navController)
                    }
                    composable("register") {
                        RegisterScreen(navController = navController)
                    }
                    composable("main") {
                        MainScreen(navController = navController)
                    }
                    composable("profile") {
                        ProfileScreen(navController = navController)
                    }
                    composable("postDetail/{postId}") { backStackEntry ->
                        val postId =
                            backStackEntry.arguments?.getString("postId")?.toIntOrNull() ?: 0
                        PostDetailScreen(navController, postId)
                    }
                    composable("about") {
                        AboutScreen(navController = navController)
                    }
                    composable("help") {
                        HelpAndFeedbackScreen(navController = navController)
                    }
                    composable("settings") {
                        SettingsScreen(navController = navController)
                    }
                    composable("createPost") {
                        CreatePostScreen(navController = navController)
                    }
                }
            }
        }
    }
}
